#!/usr/bin/perl -w

use strict;
use ui;

ui::init();
print "inited.\n";

my $scr = {stline => $ui::LINES-2,
           helpline=>0,
	   ifrom=>1,
	   ito=>$ui::LINES-3,
	  };
while(1) {
   redraw($scr);
   my $x = ui::getkey();
   ui::refresh();
   last if $x eq 'q';
}
ui::done();
print "ended.\n";


sub redraw_status {
    my $scr = shift;
    return unless defined $scr->{stline};
    ui::addstr($scr->{stline}, 0, "Status line, mwahahaha");
}

sub redraw_help {
    my $scr = shift;
    return unless defined $scr->{helpline};
    ui::addstr($scr->{helpline}, 0, "Help line!");
}

sub redraw {
    my $scr = shift;
    # TODO {changed} checks
    redraw_status($scr) if defined $scr->{stline};
    redraw_help($scr) if defined $scr->{helpline};
    ui::addstr($_, 0, "line $_") for ($scr->{ifrom}..$scr->{ito});
}

